﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetworkLib.Utilities;
using PBO.Network;
using PBO.Network.Enumerations;
using PBO.Network.Domain;

namespace PokemonBattle.BattleRoom.Server
{
    public class ChallengeInfo : DataByteArray
    {
        public BattleMode BattleMode { get; set; }
        public BattleLinkMode LinkMode { get; set; }
        public BattleRule[] Rules { get; set; }

        #region abstract

        public override void Read(ByteArray byteArray)
        {
            BattleMode = (BattleMode)byteArray.ReadInt();
            LinkMode = BattleLinkModeHelper.Parse(byteArray.ReadInt());
            this.Rules = DataByteArray.ReadArray<BattleRule>(byteArray, b => (BattleRule)b.ReadInt());
        }

        public override void Write(ByteArray byteArray)
        {
            byteArray.WriteInt((int)this.BattleMode);
            byteArray.WriteInt((int)this.LinkMode);
            DataByteArray.WriteArray<BattleRule>(this.Rules, byteArray, (b, t) => b.WriteInt((int)t));
        }

        #endregion

    }
}